package p5.MasterMindApp;

import org.omg.CORBA.ORB;
import java.util.*;
class MasterMindImpl extends MasterMindPOA {

	private double num;
	private String str;
	
	public MasterMindImpl(String str){	
		this.str = str.toUpperCase();
		System.out.println("Paraula secreta: "+this.str);
	}
	
	public double numeroJugadas() {
		return num;
	}

	public Resultado revisarJugada(String s) {
		num++;
		double weak = 0;
		double strong = 0;
		s = s.toUpperCase();
		
		for(int i = 0; i < s.length(); i++){
			for(int j = 0; j < str.length(); j++){
				if(s.charAt(i) == str.charAt(j)){
					if(i == j) strong++;
					else weak++;
					break;
				}
			}
		}
		
		return new Resultado(weak,strong);
	}
}